window.Model = function()
{
    this.listItem = null;

    this.condItem = {};

    this.condTmpItem = {};

    this.submitConditionItem = {};
}

Model.prototype = {

    getData : function()
    {
        return this.listItem;
    },

    setData : function( items )
    {
        this.listItem = items || null;
    },

    getCondItem : function()
    {
        return this.condItem;
    },

    setCondItem : function( items )
    {
        this.condItem = items || null;
    },

    /** 设置当前数据*/
    getTmpCondItem : function( )
    {
        return this.condTmpItem;
    },

    /** 获取数据模型初始数据*/
    setTmpCondItem : function( items )
    {
        this.condTmpItem = items || null;
    },

    setSubmitCondition : function( items )
    {
        this.submitConditionItem = items || null;
    },

    getSubmitCondition : function()
    {
        return this.submitConditionItem;
    },


    each : function( object, callback )
    {
        if( object instanceof Array )
        {
            for( var k = 0, f; f = object[ k ]; k += 1 )
            {
                typeof callback == "function" && callback.call( this, k, f );
            }
        }
        else if( object instanceof Object )
        {
            for( k in object )
            {
                typeof callback == "function" && callback.call( this, k, object[ k ] )
            }
        };
    },

    findItem : function( attr, value )
    {
        var item = {};

        this.each( this.listItem, function( i, t )
        {
            if( t[ attr ] == value )
            {
                item = t;
            }
        });

        return item;
    }
}




